import { arrayToJson } from '@/common/js/util.js'

// 问卷类型
export const actionType = function(isJson = false) {
    const actionList = [         
        { name: "单选题", id: 1 },
        { name: "多选题", id: 2 },
        { name: "问答题", id: 3 }
    ]
    if (isJson) {
        return arrayToJson(actionList, "id")
    }
    return actionList
}

// 快速题型
export const questionType = function(isJson = false) {
    const actionList = [
        {
            name: '姓名', question: {
                question_id: 0, title: "您的姓名是：", type: 3, is_required: false, sort: 1, is_shrink: false, multi_rows: 0, options: []
            }
        },
        {
            name: '性别', question: {
                question_id: 0, title: "您的性别是：", type: 1, is_required: false, sort: 1, is_shrink: false, options: [
                    { title: "男", sort: 1, next: '', is_write: false },
                    { title: "女", sort: 2, next: '', is_write: false }
                ]
            }
        },
        {
            name: '手机号', question: {
                question_id: 0, title: "请输入您的手机号：", type: 3, is_required: false, sort: 1, is_shrink: false, multi_rows: 0, options: []
            }
        },
        {
            name: '地区', question: {
                question_id: 0, title: "请选择地区：", type: 3, is_required: false, sort: 1, is_shrink: false, multi_rows: -1, options: [
                    { title: "", sort: 1, type: 'area' }
                ]
            }
        },
        {
            name: '日期', question: {
                question_id: 0, title: "请选择日期：", type: 3, is_required: false, sort: 1, is_shrink: false, multi_rows: -1, options: [
                    { title: "", sort: 1, type: 'date' }
                ]
            }
        },
        {
            name: '评分', question: {
                question_id: 0, title: "请选择分数：", type: 3, is_required: false, sort: 1, is_shrink: false, multi_rows: -1, options: [
                    { title: "", sort: 1, type: 'rate', texts: ['1分', '2分', '3分', '4分', '5分'] }
                ]
            }
        },
        {
            name: '满意度', question: {
                question_id: 0, title: "请选择满意度：", type: 3, is_required: false, sort: 1, is_shrink: false, multi_rows: -1, options: [
                    { title: "", sort: 1, type: 'rate', texts: ['很不满意', '不满意', '一般', '满意', '非常满意'] }
                ]
            }
        }
    ]
    if (isJson) {
        return arrayToJson(actionList, "id")
    }
    return actionList
}

export const rowsType = function() {
    return [
        { name: '单行', value: 0 },
        { name: '多行', value: 1 }
    ]
}

// 问卷状态
export const statusType = function(isJson = false) {
    const statusList = [       
        { name: '未启用', value: 0 },
        { name: '已启用', value: 1 },
        { name: '已结束', value: 2 },
        { name: '已停用', value: 3 }
    ]
    if (isJson) {
        return arrayToJson(statusList, "value")
    }
    return statusList
}

// 答题控制
export const limitType = function(isJson = false) {
    const limitList = [       
        { name: '只能', value: '1' },
        { name: '每天', value: '2' },
        { name: '每周', value: '3' },
        { name: '每月', value: '4' }
    ]
    if (isJson) {
        return arrayToJson(limitList, "value")
    }
    return limitList
}